package org.jivesoftware.smackx.packet;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jivesoftware.smack.packet.IQ;

public class DiscoverInfo extends IQ
{
  private final List<Feature> features = new CopyOnWriteArrayList();
  private final List<Identity> identities = new CopyOnWriteArrayList();
  private String node;

  private void addFeature(Feature paramFeature)
  {
    synchronized (this.features)
    {
      this.features.add(paramFeature);
      return;
    }
  }

  public void addFeature(String paramString)
  {
    addFeature(new Feature(paramString));
  }

  public void addIdentity(Identity paramIdentity)
  {
    synchronized (this.identities)
    {
      this.identities.add(paramIdentity);
      return;
    }
  }

  // ERROR //
  public DiscoverInfo clone()
  {
    // Byte code:
    //   0: new 2	org/jivesoftware/smackx/packet/DiscoverInfo
    //   3: dup
    //   4: invokespecial 51	org/jivesoftware/smackx/packet/DiscoverInfo:<init>	()V
    //   7: astore_1
    //   8: aload_1
    //   9: aload_0
    //   10: invokevirtual 55	org/jivesoftware/smackx/packet/DiscoverInfo:getNode	()Ljava/lang/String;
    //   13: invokevirtual 58	org/jivesoftware/smackx/packet/DiscoverInfo:setNode	(Ljava/lang/String;)V
    //   16: aload_0
    //   17: getfield 26	org/jivesoftware/smackx/packet/DiscoverInfo:features	Ljava/util/List;
    //   20: astore_2
    //   21: aload_2
    //   22: monitorenter
    //   23: aload_0
    //   24: getfield 26	org/jivesoftware/smackx/packet/DiscoverInfo:features	Ljava/util/List;
    //   27: invokeinterface 62 1 0
    //   32: astore 4
    //   34: aload 4
    //   36: invokeinterface 68 1 0
    //   41: ifne +61 -> 102
    //   44: aload_2
    //   45: monitorexit
    //   46: aload_0
    //   47: getfield 28	org/jivesoftware/smackx/packet/DiscoverInfo:identities	Ljava/util/List;
    //   50: astore 5
    //   52: aload 5
    //   54: monitorenter
    //   55: aload_0
    //   56: getfield 28	org/jivesoftware/smackx/packet/DiscoverInfo:identities	Ljava/util/List;
    //   59: invokeinterface 62 1 0
    //   64: astore 7
    //   66: aload 7
    //   68: invokeinterface 68 1 0
    //   73: ifne +51 -> 124
    //   76: aload 5
    //   78: monitorexit
    //   79: aload_0
    //   80: invokevirtual 72	org/jivesoftware/smackx/packet/DiscoverInfo:getExtensions	()Ljava/util/Collection;
    //   83: invokeinterface 75 1 0
    //   88: astore 8
    //   90: aload 8
    //   92: invokeinterface 68 1 0
    //   97: ifne +52 -> 149
    //   100: aload_1
    //   101: areturn
    //   102: aload_1
    //   103: aload 4
    //   105: invokeinterface 78 1 0
    //   110: checkcast 6	org/jivesoftware/smackx/packet/DiscoverInfo$Feature
    //   113: invokespecial 41	org/jivesoftware/smackx/packet/DiscoverInfo:addFeature	(Lorg/jivesoftware/smackx/packet/DiscoverInfo$Feature;)V
    //   116: goto -82 -> 34
    //   119: astore_3
    //   120: aload_2
    //   121: monitorexit
    //   122: aload_3
    //   123: athrow
    //   124: aload_1
    //   125: aload 7
    //   127: invokeinterface 78 1 0
    //   132: checkcast 9	org/jivesoftware/smackx/packet/DiscoverInfo$Identity
    //   135: invokevirtual 80	org/jivesoftware/smackx/packet/DiscoverInfo:addIdentity	(Lorg/jivesoftware/smackx/packet/DiscoverInfo$Identity;)V
    //   138: goto -72 -> 66
    //   141: astore 6
    //   143: aload 5
    //   145: monitorexit
    //   146: aload 6
    //   148: athrow
    //   149: aload_1
    //   150: aload 8
    //   152: invokeinterface 78 1 0
    //   157: checkcast 82	org/jivesoftware/smack/packet/PacketExtension
    //   160: invokevirtual 86	org/jivesoftware/smackx/packet/DiscoverInfo:addExtension	(Lorg/jivesoftware/smack/packet/PacketExtension;)V
    //   163: goto -73 -> 90
    //
    // Exception table:
    //   from	to	target	type
    //   23	46	119	finally
    //   102	122	119	finally
    //   55	79	141	finally
    //   124	146	141	finally
  }

  public boolean containsFeature(String paramString)
  {
    int i;
    Iterator localIterator = getFeatures();
    if (!(localIterator.hasNext()))
      i = 0;
    while (true)
    {
      do
        return i;
      while (!(paramString.equals(((Feature)localIterator.next()).getVar())));
      i = 1;
    }
  }

  // ERROR //
  public String getChildElementXML()
  {
    // Byte code:
    //   0: new 102	java/lang/StringBuilder
    //   3: dup
    //   4: invokespecial 103	java/lang/StringBuilder:<init>	()V
    //   7: astore_1
    //   8: aload_1
    //   9: ldc 105
    //   11: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   14: pop
    //   15: aload_0
    //   16: invokevirtual 55	org/jivesoftware/smackx/packet/DiscoverInfo:getNode	()Ljava/lang/String;
    //   19: ifnull +26 -> 45
    //   22: aload_1
    //   23: ldc 111
    //   25: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   28: pop
    //   29: aload_1
    //   30: aload_0
    //   31: invokevirtual 55	org/jivesoftware/smackx/packet/DiscoverInfo:getNode	()Ljava/lang/String;
    //   34: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   37: pop
    //   38: aload_1
    //   39: ldc 113
    //   41: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   44: pop
    //   45: aload_1
    //   46: ldc 115
    //   48: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   51: pop
    //   52: aload_0
    //   53: getfield 28	org/jivesoftware/smackx/packet/DiscoverInfo:identities	Ljava/util/List;
    //   56: astore 4
    //   58: aload 4
    //   60: monitorenter
    //   61: aload_0
    //   62: getfield 28	org/jivesoftware/smackx/packet/DiscoverInfo:identities	Ljava/util/List;
    //   65: invokeinterface 62 1 0
    //   70: astore 6
    //   72: aload 6
    //   74: invokeinterface 68 1 0
    //   79: ifne +60 -> 139
    //   82: aload 4
    //   84: monitorexit
    //   85: aload_0
    //   86: getfield 26	org/jivesoftware/smackx/packet/DiscoverInfo:features	Ljava/util/List;
    //   89: astore 8
    //   91: aload 8
    //   93: monitorenter
    //   94: aload_0
    //   95: getfield 26	org/jivesoftware/smackx/packet/DiscoverInfo:features	Ljava/util/List;
    //   98: invokeinterface 62 1 0
    //   103: astore 10
    //   105: aload 10
    //   107: invokeinterface 68 1 0
    //   112: ifne +56 -> 168
    //   115: aload 8
    //   117: monitorexit
    //   118: aload_1
    //   119: aload_0
    //   120: invokevirtual 118	org/jivesoftware/smackx/packet/DiscoverInfo:getExtensionsXML	()Ljava/lang/String;
    //   123: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   126: pop
    //   127: aload_1
    //   128: ldc 120
    //   130: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   133: pop
    //   134: aload_1
    //   135: invokevirtual 123	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   138: areturn
    //   139: aload_1
    //   140: aload 6
    //   142: invokeinterface 78 1 0
    //   147: checkcast 9	org/jivesoftware/smackx/packet/DiscoverInfo$Identity
    //   150: invokevirtual 126	org/jivesoftware/smackx/packet/DiscoverInfo$Identity:toXML	()Ljava/lang/String;
    //   153: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   156: pop
    //   157: goto -85 -> 72
    //   160: astore 5
    //   162: aload 4
    //   164: monitorexit
    //   165: aload 5
    //   167: athrow
    //   168: aload_1
    //   169: aload 10
    //   171: invokeinterface 78 1 0
    //   176: checkcast 6	org/jivesoftware/smackx/packet/DiscoverInfo$Feature
    //   179: invokevirtual 127	org/jivesoftware/smackx/packet/DiscoverInfo$Feature:toXML	()Ljava/lang/String;
    //   182: invokevirtual 109	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   185: pop
    //   186: goto -81 -> 105
    //   189: astore 9
    //   191: aload 8
    //   193: monitorexit
    //   194: aload 9
    //   196: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   61	85	160	finally
    //   139	165	160	finally
    //   94	118	189	finally
    //   168	194	189	finally
  }

  public Iterator<Feature> getFeatures()
  {
    synchronized (this.features)
    {
      Iterator localIterator = Collections.unmodifiableList(this.features).iterator();
      return localIterator;
    }
  }

  public Iterator<Identity> getIdentities()
  {
    synchronized (this.identities)
    {
      Iterator localIterator = Collections.unmodifiableList(this.identities).iterator();
      return localIterator;
    }
  }

  public String getNode()
  {
    return this.node;
  }

  public void setNode(String paramString)
  {
    this.node = paramString;
  }

  public static class Feature
  {
    private String variable;

    public Feature(String paramString)
    {
      this.variable = paramString;
    }

    public String getVar()
    {
      return this.variable;
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append("<feature var=\"").append(this.variable).append("\"/>");
      return localStringBuilder.toString();
    }
  }

  public static class Identity
  {
    private String category;
    private String name;
    private String type;

    public Identity(String paramString1, String paramString2)
    {
      this.category = paramString1;
      this.name = paramString2;
    }

    public String getCategory()
    {
      return this.category;
    }

    public String getName()
    {
      return this.name;
    }

    public String getType()
    {
      return this.type;
    }

    public void setType(String paramString)
    {
      this.type = paramString;
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append("<identity category=\"").append(this.category).append("\"");
      localStringBuilder.append(" name=\"").append(this.name).append("\"");
      if (this.type != null)
        localStringBuilder.append(" type=\"").append(this.type).append("\"");
      localStringBuilder.append("/>");
      return localStringBuilder.toString();
    }
  }
}